package cn.driver.servicecourse.service.impl;

import cn.driver.common.pojo.Course;
import cn.driver.servicecourse.mapper.CourseMapper;
import cn.driver.servicecourse.service.CourseService;
import cn.driver.servicecourse.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServieImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public List<Course> selectList(int pageNo, int pageSize, String prm) {
        return courseMapper.selectList((pageNo - 1) * pageSize, pageSize, prm);
    }

    @Override
    public int selectCount(String prm) {
        return courseMapper.selectCount(prm);
    }

    @Override
    public Course selectOne(int id) {
        return courseMapper.selectOne(id);
    }

    @Override
    public int add(Course course) {
        return courseMapper.add(course);
    }

    @Override
    public int update(Course course) {
        return courseMapper.update(course);
    }

    @Override
    public int del(int id) {
        return courseMapper.del(id);
    }

    @Override
    public Pager<Course> pageInfo(int pageNo, int pageSize, String prm) {
        Pager<Course> pager = new Pager<Course>();
        pager.setPageNo(pageNo);
        pager.setPageSize(pageSize);
        pager.setList(this.selectList(pageNo, pageSize, prm));
        pager.setTotalCount(this.selectCount(prm));
        return pager;
    }
}
